package xyz.showbooks.aop;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import xyz.showbooks.vo.util.JsonResult;

/**
 * @author: Dsi
 * @date: 2022/2/18 9:30
 * @description:
 */
@RestControllerAdvice
public class SystemException {
    /**
     * 拦截：运行时异常
     * 返回值：SysResult对象的status的属性值--201
     * @ExceptionHandler: 切入点表达式
     * */
    @ExceptionHandler(RuntimeException.class)
    public JsonResult fail(Exception e){
        e.printStackTrace();
        return JsonResult.build().code(201).data(null).msg("未知错误，业务失败");
    }
}
